package com.climber.android.commonres.helper

import android.webkit.CookieManager
import android.webkit.CookieSyncManager
import io.ganguo.library.dswebview.WebUICacheHelper
import io.ganguo.library.mvp.util.AppUtils

/**
 * Created by Mikes at 2019-07-29 15:18
 */
object WebCacheHelper {
    @JvmStatic
    fun clearWebStorageAndCookie() {
        WebUICacheHelper.clearWebKitCache(AppUtils.getApp())

        clearCookie()
    }

    private fun clearCookie() {
        val cookieSyncManager = CookieSyncManager.createInstance(AppUtils.getApp())
        val cookieManager = CookieManager.getInstance()
        cookieManager.setAcceptCookie(true)
        cookieManager.removeSessionCookie()

        cookieManager.removeAllCookie()
        cookieSyncManager.sync()
    }
}
